//
//  TimeTableViewCell.swift
//  Exchange
//
//  Created by 孟祥群 on 2018/6/12.
//  Copyright © 2018年 common. All rights reserved.
//

import UIKit
protocol  TimeDelegate:class{
    func delegate(index:Int)
}
class TimeTableViewCell: BaseTableViewCell {
    var index:Int = 0
    weak var delegate:TimeDelegate?
    lazy var dateLabel:UILabel = {
       let label = BaseLabel(style: .oneStyle)
        label.numberOfLines = 0
       label.font = UIFont.systemFont(ofSize: 13)
        return label
    }()
    
    lazy var timeLabel: UILabel = {
       let label = BaseLabel(style: .oneStyle)
        label.font = UIFont.systemFont(ofSize: 13)
        return label
    }()
    lazy var delegateBtn:CustomBtn = {
        let btn = CustomBtn(frame: CGRect.zero)
        btn.addTarget(self, action: #selector(delegateBtnAction(sender:)), for: UIControlEvents.touchUpInside)
        btn.photoImageView.image = UIImage(named: "delegateTime")
        return btn
    }()
    override func setUpUI() {
        let view = UIView()
        self.contentView.addSubview(view)
        view.themeBackground = ThemeManager.ThemeColorKeys.background
        view.snp.makeConstraints { (make) in
            make.left.equalToSuperview().offset(16)
            make.right.equalToSuperview().offset(-16)
            make.top.bottom.equalToSuperview()
        }
        
        
        view.addSubview(dateLabel)
        dateLabel.snp.makeConstraints { (make) in
            make.left.equalToSuperview().offset(15)
            make.right.equalToSuperview().offset(-15)
            make.top.equalToSuperview().offset(20)
        }
        
        view.addSubview(timeLabel)
        timeLabel.snp.makeConstraints { (make) in
            make.left.equalToSuperview().offset(15)
            make.right.equalToSuperview().offset(-15)
            make.top.equalTo(dateLabel.snp.bottom).offset(10)
        }
        
        let line:UIView = UIView()
        line.themeBackground = ThemeManager.ThemeColorKeys.tabLineColor
        self.contentView.addSubview(line)
        line.snp.makeConstraints { (make) in
            make.left.equalToSuperview().offset(15)
            make.bottom.equalToSuperview().offset(-0.5)
            make.right.equalToSuperview().offset(-15)
            make.height.equalTo(0.5)
        }
    
        self.contentView.addSubview(delegateBtn)
        delegateBtn.snp.makeConstraints { (make) in
            make.top.equalToSuperview()
            make.right.equalToSuperview().offset(-15)
            make.height.width.equalTo(50)
        }
        
        delegateBtn.photoImageView.snp.makeConstraints { (make) in
            make.centerX.centerY.equalToSuperview()
        }
        
    }
    
    @objc func delegateBtnAction(sender:CustomBtn) {
        if delegate != nil {
            self.delegate?.delegate(index: index)
        }
    }
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}
